package com.totem.admin.controller;

import com.totem.admin.api.AdminCustomerServiceApi;
import com.totem.admin.service.IAdminCustomerService;
import com.totem.base.model.PageVO;
import com.totem.base.model.Result;
import com.totem.base.mybatis.controller.BaseController;
import com.totem.customer.model.TCustomers;
import com.totem.customer.serivce.ITCustomerService;
import com.totem.customer.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class AdminCustomerController extends BaseController<ITCustomerService, TCustomers> implements AdminCustomerServiceApi {
    @Autowired
    private IAdminCustomerService iAdminCustomerService;
    @Override
    public Result<Boolean> update(CustomerUpdateVO vo) {
        return Result.result("修改客户信息成功", "修改客户信息失败", service.updateCustomer(vo));
    }
    @Override
    public Result<Boolean> delete(CustomerDelVO vo) {
        boolean result = service.removeById(currentCustomerId());
        return Result.result("删除客户成功", "删除客户失败", result);
    }
    @Override
    public Result<PageVO<CustomerVO>> customerPage(CustomerPageVO vo) {
        return Result.success(service.customerPage(vo));
    }
    @Override
    public Result<CustomerVO> getVoById(Long id) {
        return Result.success(service.getVoById(id));
    }
    @Override
    public Result<CustomerLoginVO> login(CustomerLoginVO vo) {
        return Result.success(iAdminCustomerService.login(vo));
    }
    @Override
    public Result<Boolean> logout(CustomerLogoutVO vo) {
        return Result.success(service.logout());
    }
    @Override
    public Result<Boolean> updatePassword(UpdatePasswordVO vo) {
        boolean result =service.updatePassword(vo);
        return Result.result("更新密码成功", "更新密码失败", result);
    }
    @Override
    public Result<Boolean> updateTxPassword(UpdateTxPasswordVO vo) {
        boolean result = service.updateTxPassword(vo);
        return Result.result("更新交易密码成功", "更新交易密码失败", result);
    }
}
